#ifndef THINK_THINK_CONSOLE_OUTPUT_QUESTION_CONFIRMATION_H
#define THINK_THINK_CONSOLE_OUTPUT_QUESTION_CONFIRMATION_H

static char* think_console_output_question_confirmation =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: yunwuxin <448901948@qq.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\console\\output\\question;\n"
	"\n"
	"use think\\console\\output\\Question;\n"
	"\n"
	"class Confirmation extends Question\n"
	"{\n"
	"\n"
	"    private $trueAnswerRegex;\n"
	"\n"
	"    /**\n"
	"     * 构造方法\n"
	"     * @param string $question        问题\n"
	"     * @param bool   $default         默认答案\n"
	"     * @param string $trueAnswerRegex 验证正则\n"
	"     */\n"
	"    public function __construct($question, $default = true, $trueAnswerRegex = \'/^y/i\')\n"
	"    {\n"
	"        parent::__construct($question, (bool) $default);\n"
	"\n"
	"        $this->trueAnswerRegex = $trueAnswerRegex;\n"
	"        $this->setNormalizer($this->getDefaultNormalizer());\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取默认的答案回调\n"
	"     * @return callable\n"
	"     */\n"
	"    private function getDefaultNormalizer()\n"
	"    {\n"
	"        $default = $this->getDefault();\n"
	"        $regex   = $this->trueAnswerRegex;\n"
	"\n"
	"        return function ($answer) use ($default, $regex) {\n"
	"            if (is_bool($answer)) {\n"
	"                return $answer;\n"
	"            }\n"
	"\n"
	"            $answerIsTrue = (bool) preg_match($regex, $answer);\n"
	"            if (false === $default) {\n"
	"                return $answer && $answerIsTrue;\n"
	"            }\n"
	"\n"
	"            return !$answer || $answerIsTrue;\n"
	"        };\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif